﻿<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/struts-html" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean" prefix="bean" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%request.setAttribute("ctx",request.getContextPath()); %>
<html>
<head>
<link href="${ctx}/extend/css/style.css" rel="stylesheet" type="text/css"/>
<script src="${ctx}/extend/js/jquery/jquery.js" type="text/javascript"></script>
<script src="${ctx}/extend/js/dutil/DUtil.js" type="text/javascript"></script>
<script src="${ctx}/extend/css/css.js" type="text/javascript"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link href="${ctx}/css/style.css" rel="stylesheet" type="text/css"/>
<script src="${ctx}/js/common.js" type="text/javascript"></script>
<script src="${ctx}/js/check.js" type="text/javascript"></script>
<script src="${ctx}/js/utils.js" type="text/javascript"></script>
<script src="${ctx}/js/common/merdiseSort.js" type="text/javascript"></script>
<title>添加新资产</title>

</head>


<body class="maintable">
<form name="merchandiseForm" method="POST" id="reMdForm" action="saveRecord" enctype="multipart/form-data">
<div id="div_all_document" style="height:100%;overflow-y:auto;position:relative;word-wrap: break-word; word-break: break-all;">
<div class="dclass_container" >
	<div class="dclass_container_header" >    	
        <div class="dclass_container_title">添加新资产</div>
    </div>
    
    <div class="dclass_container_content">

	<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#9FD6FF">
         <tr>           
			<td width="20%" class="formtitle">资产号:<span class="fontred">*</span></td>
            <td width="30%" class="formtd"><input name="reMd.assetsNum" id="assetsNum" type="text" class="inputform" value=""></td>
            <td width="20%" class="formtitle"></td>
            <td width="30%" class="formtd"></td>
          </tr>
         <tr>           
			<td width="20%" class="formtitle">自编号:</td>
            <td width="30%" class="formtd"><input name="reMd.selfNum" id="selfNum" type="text" class="inputform" value=""></td>
            <td width="20%" class="formtitle">公司名称:</td>
            <td width="30%" class="formtd"> <input name="reMd.compName" id="compName" type="text" class="inputform" value=""></td>
          </tr>
          <tr>           
			<td width="20%" class="formtitle">业务类型:</td>
            <td width="30%" class="formtd"><input name="reMd.busType" id="busType" type="text" class="inputform" value=""></td>
            <td width="20%" class="formtitle">项目/工程号:</td>
            <td width="30%" class="formtd"> <input name="reMd.projNum" id="projNum" type="text" class="inputform" value=""></td>
          </tr>
          <tr>           
			<td width="20%" class="formtitle">项目/工程名称:</td>
            <td width="30%" class="formtd"><input name="reMd.projName" id="projName" type="text" class="inputform" value=""></td>
             <td width="20%" class="formtitle">资产类型:</td>
            <td class="formtd">
				<select name="reMd.prodType" >
					<option value="">请选择</option>
					<c:forEach var="cvar"  items="${prodType}">
						<option value="${cvar.key}">${cvar.value}</option>
					</c:forEach>
				</select>
			</td>
          </tr>
          <tr>           
			<td width="20%" class="formtitle">资产分类:</td>
			<td class="formtd">
				<select name="reMd.prodClass" >
					<option value="">请选择</option>
					<c:forEach var="cvar"  items="${prodClass}">
						<option value="${cvar.key}">${cvar.value}</option>
					</c:forEach>
				</select>
			</td>
			<td width="20%" class="formtitle">设备分类:</td>
            <%-- <td class="formtd">
				<select name="reMd.equipClass" >
					<option value="">请选择</option>
					<c:forEach var="cvar"  items="${equipClass}">
						<option value="${cvar.key}">${cvar.value}</option>
					</c:forEach>
				</select>
			</td> --%>
			<td width="30%" class="formtd"><input name="reMd.equipClass" id="equipClass" type="text" class="inputform" value=""></td>
          </tr>
          <tr>           
			<td width="20%" class="formtitle">设备类型:</td>
            <td width="30%" class="formtd"><input name="reMd.equipType" id="equipType" type="text" class="inputform" value=""></td>
            <td width="20%" class="formtitle">设备名称:</td>
            <td width="30%" class="formtd"> <input name="reMd.equipName" id="equipName" type="text" class="inputform" value=""></td>
          </tr>
          <tr>            
			<td width="20%" class="formtitle">设备别名:</td>
            <td width="30%" class="formtd"><input name="reMd.equipNickName" id="equipNickName" type="text" class="inputform" value=""></td>
            <td width="20%" class="formtitle">光缆类型:</td>
            <td class="formtd">
				<select name="reMd.fiberType">
					<option value="">请选择</option>
					<c:forEach var="cvar"  items="${fiberType}">
						<option value="${cvar.key}">${cvar.value}</option>
					</c:forEach>
				</select>
			</td>
          </tr>

          <tr>           
            <td width="20%" class="formtitle">光缆芯数:<span>(正整数)</span></td>
            <td width="30%" class="formtd"> <input name="reMd.fiberNum" id="fiberNum" type="text" class="inputform" value="" ></td>
			<td width="20%" class="formtitle">光缆长度:<span>(正整数)</span></td>
            <td width="30%" class="formtd"><input name="reMd.fiberLength" id="fiberLength" type="text" class="inputform" value=""></td>
          </tr>
          <tr>           
            <td width="20%" class="formtitle">厂家名:</td>
            <td width="30%" class="formtd"> <input name="reMd.factoryName" id="factoryName" type="text" class="inputform" value="" ></td>
			<td width="20%" class="formtitle">供货商:</td>
            <td width="30%" class="formtd"><input name="reMd.provider" id="provider" type="text" class="inputform" value=""></td>
          </tr>
          <tr>           
            <td width="20%" class="formtitle">设备型号:</td>
            <td width="30%" class="formtd"> <input name="reMd.equipModel" id="equipModel" type="text" class="inputform" value="" ></td>
			<td width="20%" class="formtitle">S/N:</td>
            <td width="30%" class="formtd"><input name="reMd.sn" id="sn" type="text" class="inputform" value=""></td>
          </tr>
          <tr>
          	<td width="20%" class="formtitle">MAC:</td>
            <td width="30%" class="formtd"><input name="reMd.macAddr" id="macAddr" type="text" class="inputform" value=""></td>           
            <td width="20%" class="formtitle">模块号:</td>
            <td width="30%" class="formtd"> <input name="reMd.modelNum" id="modelNum" type="text" class="inputform" value="" ></td>
          </tr>
          <tr>
			<td width="20%" class="formtitle">规格:</td>
            <td width="30%" class="formtd"><input name="reMd.standard" id="standard" type="text" class="inputform" value=""></td>
            <td width="20%" class="formtitle">单价:<span>(正数)</span></td>
            <td width="30%" class="formtd"> <input name="reMd.unitPrice" id="unitPrice" type="text" class="inputform" value="" ></td>
          </tr>
          <tr>
			<td width="20%" class="formtitle">入库日期:<span>&nbsp;&nbsp;(系统当前日期)</span></td>
            <td width="30%" class="formtd"><input name="reMd.inputDate" id="inputDate" type="text" class="inputform" value="" readOnly></td>
            <td width="20%" class="formtitle">出库日期:<span>(yyyy-MM-dd)</span></td>
            <td width="30%" class="formtd"> <input name="reMd.manDate" id="manDate" type="text" class="inputform" value="" ></td>
          </tr>
          <tr>
			<td width="20%" class="formtitle">仓库管理人:</td>
            <td width="30%" class="formtd"><input name="reMd.wareHouseMan" id="wareHouseMan" type="text" class="inputform" value=""></td>
            <td width="20%" class="formtitle">使用日期:<span>(yyyy-MM-dd)</span></td>
            <td width="30%" class="formtd"> <input name="reMd.useDate" id="useDate" type="text" class="inputform" value="" ></td>
          </tr>
          <tr>
			<td width="20%" class="formtitle">负责人:</td>
            <td width="30%" class="formtd"><input name="reMd.chargeMan" id="chargeMan" type="text" class="inputform" value=""></td>
            <td width="20%" class="formtitle">资产管理人:</td>
            <td width="30%" class="formtd"> <input name="reMd.assetsMgnt" id="assetsMgnt" type="text" class="inputform" value="" ></td>
          </tr>
           <tr>
			<td width="20%" class="formtitle">设备所在省:</td>
            <td width="30%" class="formtd"><input name="reMd.equipLocalProvice" id="equipLocalProvice" type="text" class="inputform" value=""></td>
            <td width="20%" class="formtitle">设备所在市:</td>
            <td width="30%" class="formtd"> <input name="reMd.equipLocalCity" id="equipLocalCity" type="text" class="inputform" value="" ></td>
          </tr>
          <tr>
			<td width="20%" class="formtitle">设备所在区:</td>
            <td width="30%" class="formtd"><input name="reMd.equipLocalDistrict" id="equipLocalDistrict" type="text" class="inputform" value=""></td>
            <td width="20%" class="formtitle">设备所在村镇:</td>
            <td width="30%" class="formtd"> <input name="reMd.equipLocalTown" id="equipLocalTown" type="text" class="inputform" value="" ></td>
          </tr>
          <tr>
			<td width="20%" class="formtitle">光缆起点:</td>
            <td width="30%" class="formtd"><input name="reMd.fiberStart" id="fiberStart" type="text" class="inputform" value=""></td>
            <td width="20%" class="formtitle">光缆终点:</td>
            <td width="30%" class="formtd"> <input name="reMd.fiberEnd" id="fiberEnd" type="text" class="inputform" value="" ></td>
          </tr>
          <tr>
			<td width="20%" class="formtitle">光缆起始码号:</td>
            <td width="30%" class="formtd"><input name="reMd.fiberStartCode" id="fiberStartCode" type="text" class="inputform" value=""></td>
            <td width="20%" class="formtitle">光缆终止码号:</td>
            <td width="30%" class="formtd"> <input name="reMd.fiberEndCode" id="fiberEndCode" type="text" class="inputform" value="" ></td>
          </tr>
          <tr>            
			<td width="20%" class="formtitle">具体位置:</td>
            <td width="30%" class="formtd"><input name="reMd.exactLocation" id="exactLocation" type="text" class="inputform" value=""></td>
            <td width="20%" class="formtitle">所属机架:</td>
            <td width="30%" class="formtd"> <input name="reMd.belongFrame" id="belongFrame" type="text" class="inputform" value="" ></td>
          </tr>
          <tr>
            <td width="20%" class="formtitle">所在机框:</td>
            <td width="30%" class="formtd"><input name="reMd.localFrame" id="localFrame" type="text" class="inputform" value=""></td>
            <td width="20%" class="formtitle">所在槽道:</td>
            <td width="30%" class="formtd"> <input name="reMd.localChannel" id="localChannel" type="text" class="inputform" value="" ></td>
          </tr>
          <tr>
			<td width="20%" class="formtitle">当前状态:<span class="fontred">*</span></td>
            <td class="formtd">
				<select name="reMd.currStatus" id="currStatus">
					<option value="">请选择</option>
					<c:forEach var="cvar"  items="${currStatus}">
						<option value="${cvar.key}">${cvar.value}</option>
					</c:forEach>
				</select>
			</td>
            <%-- <td width="20%" class="formtitle">IP 地址:<span>(255.255.255.255)</span></td>
            <td width="30%" class="formtd"> <input name="reMd.ip" id="ip" type="text" class="inputform" value="" ></td> --%>
            <td width="20%" class="formtitle">设备功能:</td>
            <td width="30%" class="formtd"><input name="reMd.equipFunction" id="equipFunction" type="text" class="inputform" value=""></td>
          </tr>
          <%-- 
          <tr>           
            <td width="20%" class="formtitle">修改日期:<span>(yyyy-MM-dd)</span></td>
            <td width="30%" class="formtd"> <input name="reMd.modifyDate" id="modifyDate" type="text" class="inputform" value="" ></td>
			<td width="20%" class="formtitle">修改原因:</td>
            <td width="30%" class="formtd"><input name="reMd.modifyResult" id="modifyResult" type="text" class="inputform" value=""></td>
          </tr>
           --%>
           <tr>
            <td width="20%" class="formtitle">备注:</td>
           	<td colspan="3" width="30%" class="formtd">
            	<textarea class="inputformtext100" name="reMd.remarks" id="remarks" ></textarea>
           </td>
          </tr> 
     </table>
     <br style="line-height:5px;"/>
	<br style="line-height:5px;"/>
    <div style="padding:0.3em; text-align:center">
    	<input type="button" class="button" value="保 存" onclick="javascript:saveReMd();" />
		<input type="button" class="button" value="关 闭" onclick="javascript:history.back();" />
    </div>
	</div>
	</div>
</div>
</form>
<script type="text/javascript">
	window.onload=defaultLoadFunction();
	
	function defaultLoadFunction(){
		<%--genAssetsNum();--%>
		setInputDate();
	}
	
    function saveReMd(){
   		if(checkMd()){
			var reMdForm=document.getElementById("reMdForm");
	       	reMdForm.action="${ctx}/admin/saveRecord";
	        reMdForm.submit();
       }
    }
	function checkMd(){
		var assetsNum = document.getElementById("assetsNum");
		var currStatus = document.getElementById("currStatus");
		var fiberNum = document.getElementById("fiberNum");
		var fiberLength = document.getElementById("fiberLength");
		var unitPrice = document.getElementById("unitPrice");
		/* var ip = document.getElementById("ip"); */
		var manDate = document.getElementById("manDate");
		var useDate = document.getElementById("useDate");
		//Added by Doug
		/* var macAddr = document.getElementById("macAddr"); */
		/* var currStatusValue = document.getElementById("currStatus").value; */
		
		if (checkNull(assetsNum)){
			alert("资产号不能为空或者全部空格!");
			document.getElementById("assetsNum").focus();
			return false;
		}

		if(checkNull(currStatus)){
			alert("当前状态必须选择!");
			document.getElementById("currStatus").focus();
			return false;
		}
		
		if(!checkNull(fiberNum)) {
			if(! checkPositiveInt(fiberNum)){
				alert("光缆芯数必须是正整数!");
				document.getElementById("fiberNum").focus();
				return false;
			}
			
		}
		
		if(!checkNull(fiberLength)) {
			if(null == fiberLength){
				alert("请输入光缆长度!");
				document.getElementById("fiberLength").focus();
				return false;
				}
			
			if(! checkPositiveInt(fiberLength)){
			alert("光缆长度必须是正整数!");
			document.getElementById("fiberLength").focus();
			return false;
			}
		
		} 
		
		if(null!=unitPrice && !checkNull(unitPrice)) {
			if(! checkPrice(unitPrice)){
			alert("单价必须是正数!");
			document.getElementById("unitPrice").focus();
			return false;
			}
		}

		
		/* if(!checkNull(ip)) {
			if(!checkIp(ip)) {
				alert("IP格式不正确!");
				document.getElementById("ip").focus();
				return false;
			}
		} */
		
		if(!checkNull(manDate)) {
			if(!checkDate(manDate)) {
				alert("出库日期格式必须是 yyyy-MM-dd!");
				document.getElementById("manDate").focus();
				return false;
			}
		}
		
		if(!checkNull(useDate)) {
			if(!checkDate(useDate)) {
				alert("使用日期格式必须是 yyyy-MM-dd!");
				document.getElementById("useDate").focus();
				return false;
			}
		}
		
		//Added by Doug
		/* if(!checkNull(macAddr)) {
			if(!checkMac(macAddr)) {
				alert("mac地址格式不正确！mac地址格式为00:12:34:56:78:9A");
				document.getElementById("macAddr").focus();
				return false;
			}
		}  */
		
		//Added by Doug@20130305
		//"当前状态" should be mandatory
  		/* if( currStatusValue=='请选择')
  			{
    			alert("请设置当前状态！");
      		return false;
  		} */
		
		return true;
	}
	
	function setInputDate() {
		var inputDate = document.getElementById("inputDate");
		var currDate = getCurrDate();
		var formatVal = formatDate(currDate);
		inputDate.value = formatVal;
	}
	
	
	function genAssetsNum(){
		var assetsNum = document.getElementById("assetsNum");
		var currMillSecond = getCurrMillSeconds();
		assetsNum.value = currMillSecond;	
	}
		
</script>
</body>
</html>